<?php

namespace apiend\modules\user\models;

use Yii;

/**
 * 用户收藏的商品列表
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class HistorySearch extends \common\models\user\UserHistory {

    /**
     * @var boolean 禁用查询缓存
     */
    public $queryCacheDuration = false;

    /**
     * @var integer 用户UID
     */
    public $user_id;

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['user_id'], 'required'],
            [['user_id'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function buildQuery() {
        $query = static::find()->andWhere([
            'user_id' => $this->user_id
        ])->orderBy([
            'updated_at' => SORT_DESC,
        ]);
        $query->with('source');
        return $query;
    }

}
